<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta charset="UTF-8">
  <title>资讯详情页</title>
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/articleDetail.css">
  <script type="text/javascript" src="../lib/js/evm.js"></script>
  <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
  <script type="text/javascript" src="../lib/js/key.js"></script>
  <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/video.js"></script>
  <script>
    marqueerun = false//在public.js后面赋值，可拦截跑马灯滚动
  </script>
</head>

<body>
  <div class="articleDetail-bg" id="articleDetailMain">

    <div id="articleDetailBody">
      <div class="title"></div>
      <div class="time"></div>
      <div class="author"></div>
      <div class="view"></div>
      <div class="likeNumber"></div>
      <div class="model" id="modelImg">
        <img class="imgs" src="" alt="">
        <div class="alearts">点击可全屏并切换</div>
        <div class='confirm'>确定</div>
      </div>
      <div class="model" id="detailContain">
        <div class="container" id="detail">
          <div class="content" id="content">
          </div>
        </div>
      </div>
      <div class="model" id="like">
        点赞 <span class="model_likes"></span>
      </div>
      <div class="model" id='collection'>
        收藏 
        <!-- <span class="model_collection"></span> -->
      </div>
      <div class="share">
        <img src="">
        扫码分享
      </div>
    </div>
  </div>
</body>
<script>
  var modelIndex = {
    disUser: true,
    //isVideo: true,
    index: 1, //初始位置
    listName: 'model', //模块名称
    containerId: 'articleDetailBody', //包含模块的标签id
    thisContain: 'detailContain', //翻滚外容器
    thisDetail: 'detail', //翻滚内容
  }

  var articleRun;
  var photos;
  function direOpt(index, directive) {
    if (directive == "up") {//上
      if (index == 1) {//文章翻滚
        TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      } else if (index == 2 || index == 3) {
        index = 0;
      }
    } else if (directive == "down") {//下
      if (index == 1) {//文章翻滚
        TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      } else if (index == 0) {
        index = 2;
      }
    } else if (directive == 'forwards') {
      if (index == 0) {
        index = 1
      } else if (index == 1 || index == 2) {
        index++
      } else if (index == 3) {
        index = 1
      }
      clearInterval(articleRun);
    } else if (directive == 'backwards') {
      if (index == 1) {
        index = 0
      } else if (index == 2 || index == 3) {
        index--;
      }
      clearInterval(articleRun);
    }
    return index;
  }

  function getMessage() {
    var access_token = $.cookie('TV_CST_TOKEN');
    var param = {
      id: TV.GetParam('id'),
      access_token: access_token,
      // area_id: $.cookie('TV_CST_AREA')
    }
    GetDatas('getArticle', param, function (err, res) {
      var mess = res.data;
      photos = mess.images.length == 0 ? mess.img : mess.images;
      console.log(mess)
      $('.content').html(mess.content);
      $('.title').html(mess.title)
      $('.time').html(mess.format_add_time)
      $('.author').html('来源：' + mess.area_name)
      $('.view').html(mess.click_count)
      $('.likeNumber').html(mess.likes)
      $('.model_likes').html(mess.likes)
      $('.model_collection').html(mess.collection_count)

      if (mess.img) {
        $('.imgs').attr('src', API_URL['imgURL'] + mess.img);
      } else {
        $('.imgs').attr('src', '../images/base.png');
      }
      if (mess.is_like == 1) {
        $('#like').css('background-image', 'url(../images/like-2.png)')
      }
      if (access_token == "" || access_token == null) {
        var surl = API_URL.loginURL + "home/index/qrcode?url=" + encodeURIComponent(
          API_URL.WXUrlDetail + '/' + TV.GetParam('id'));
      } else {
        var surl = API_URL.loginURL + "home/index/qrcode?url=" + encodeURIComponent(
          API_URL.WXUrlDetail + '/' + TV.GetParam('id'))
      }
      $('.share img').attr('src', surl)

    })
  }
  getMessage();

  function direEnter(index) {
    if (index == 0 && photos && photos.length) {
      window.location.href = './A_DetailPhoto.html?id=' + TV.GetParam('id');
    } else if (index == 1) {
      clearInterval(articleRun);
    } else if (index == 2) {
      var access_token = $.cookie('TV_CST_TOKEN');
      var param = {
        id: TV.GetParam('id'),
        access_token: access_token,
      }
      GetDatas('dianzan', param, function (err, res) {
        console.log(res)
        if (res.code == 0) {
          TV.PromptMsg('点赞成功')
          $(".likeNumber").html(res.data.likes);
          $(".model_likes").html(res.data.likes);

          $('#like').css('background-image', 'url(../images/like-2.png)')
        } else if (res.code == 10009) {

          TV.userLogin();
          direEnter(index);
          // alert('111')
        } else {
          var message = res.message
          TV.PromptMsg(message)
        }
      })
    } else if (index == 3) {
      var access_token = $.cookie('TV_CST_TOKEN');
      var param = {
        id: TV.GetParam('id'),
        cardNum: 233,
        // cardNo: hardware.STB.serialNumber,
      }
      GetDatas('collection', param, function (err, res) {
        console.log(res)
        if (res.code == 0) {
          TV.PromptMsg('收藏成功')
          $(".cur-number").eq(index).html(res.data.collection_count);
          // $(".model_collection").html(res.data.collection_count);

          $('#collection').css('background-image', 'url(../images/collection.png)')
        } else if (res.code == 10009) {
          TV.userLogin();
          direEnter(index);
          // alert('111')
        } else {
          var message = res.message
          TV.PromptMsg(message)
          $('#collection').css('background-image', 'url(../images/collection-1.png)')
        }
      })
    }
  }

</script>
<script type="text/javascript" src="../js/index.js"></script>

</html>